﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WinUI
{
    public static class Extensions
    {
        public static TEnumType GetEnumFromString<TEnumType>(this string value) where TEnumType : struct, IConvertible
        {
            if (!typeof(TEnumType).IsEnum)
            {
                throw new ArgumentException("T must be an enumerated type");
            }
            try
            {
                return (TEnumType)Enum.Parse(typeof(TEnumType), value);
            }
            catch
            {
                throw new Exception("Error while pasrsin value to Enum");
            }
        }
    }
}